package com.example.home.adapter

import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.home.R
import com.example.home.databinding.ItemHomeCategoryItemCardViewBinding
import com.example.home.databinding.ItemHomeSubjectItemCardViewBinding
import com.example.home.entity.discover.CardDataItemData
import com.example.home.entity.discover.SubjectCardItemData

/**
 * 分类Item的适配器
 * */
class SubjectItemAdapter constructor(layoutId : Int): BaseQuickAdapter<SubjectCardItemData,BaseViewHolder>(layoutId) {

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        DataBindingUtil.bind<ItemHomeSubjectItemCardViewBinding>(viewHolder.itemView)
    }

    override fun convert(holder: BaseViewHolder, item: SubjectCardItemData) {
        var dataBinding= holder.getBinding<ItemHomeSubjectItemCardViewBinding>()

        if (item != null && dataBinding!= null){
            dataBinding.viewData=item
            dataBinding.executePendingBindings()
        }
    }

}